﻿{include file="public/header" /}

<body >
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">图纸管理</a>
        <a>
          <cite>外部图纸</cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
        <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>
        <button class="layui-btn" onclick="x_admin_show('添加外图','{:url(\'index/blueprint/addDrawingExterna\')}',500,400)"><i class="layui-icon"></i>添加</button>
        <div class="layui-input-inline">
            <form class="layui-form" action="{:url('index/Blueprint/blueprintOutside')}" method="post">
                <div class="layui-input-inline">
                    <input type="text" name="modules" autocomplete="off" placeholder="请输入关键字..." class="layui-input">
                </div>
                {if $mode == 1}
                <input type="hidden" name="model" value="1">
                <input type="hidden" name="order" value="{$order}">
                {/if}
                <div class="layui-input-inline">
                    <select name="id" lay-search="" >
                        <option value=""></option>
                        <optgroup label="外图编号">
                            {volist name="$blueprintOutside" id="outside"}
                            <option value="{$outside.id}">{$outside.drawing_external_id}</option>
                            {/volist}
                        </optgroup>
                    </select>
                </div>
                <button type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </form>
        </div>
        <span class="x-right" style="line-height:40px">共{$blueprintOutsideCount}条 · 共{$blueprintOutsideCount/25|getInt}页</span>
        {if $mode == 1}
         <button class="layui-btn" onclick="exeOrder()"><i class="layui-icon"></i>生成订单明细</button>
        {/if}
    </xblock>
<div class="container-wrap">
    <div class="box-1">
        <table class="layui-table">
            <thead>
                <tr>
                    {if $mode == 1}
                    <th width="20px;">
                        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                    </th>
                    {/if}
                    <th width="30px;">操作</th>
                    <th>外来图号</th>
                    <th>建档日期</th>
                    <th>创建人</th>
                    <th>修改人</th>
                    <th>修改日期</th>
                    <th>备注</th>
                </tr>
            </thead>
            <tbody>
            {volist name="$blueprintOutside" id="blueprintOutsideList"}
            <tr>
                <?php
                    $count = getDetialExternal($blueprintOutsideList['drawing_external_id']);
                 ?>
                {if $mode == 1}
                {if $count != 0}
                <td>
                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$blueprintOutsideList.drawing_external_id}'><i class="layui-icon">&#xe605;</i></div>
                </td>
                {else/}
                <td></td>
                {/if}
                {/if}
                <td class="td-manage">
                    <a title="修改" onclick="x_admin_show('修改外图','{:url(\'index/Blueprint/outsideEdit\',[\'id\'=>$blueprintOutsideList.id])}',400,400)", href="javascript:;"><i style="color: green" class="layui-icon"></i></a>
                    <a title="删除" onclick="delete_(this,'{$blueprintOutsideList.id}')" href="javascript:void(0);" ><i  style="color:red;" class="layui-icon"></i></a>
                    <a title="添加明细" onclick="x_admin_show('为外图 <span class=\'layui-badge layui-bg-blue\'>{$blueprintOutsideList.drawing_external_id}</span> 添加明细','{:url(\'index/blueprint/addDrawingDetial\', [\'id\' => $blueprintOutsideList.drawing_external_id])}')" href="javascript:;"><i style="color: green" class="iconfont nav_right">&#xe6b9;</i></a>
                    {if !widget('Widget/drawing_check',['drawing_id'=>$blueprintOutsideList.drawing_external_id])}
                    <a title="上传文件" onclick="x_admin_show('为外图 <span class=\'layui-badge layui-bg-blue\'>{$blueprintOutsideList.drawing_external_id}</span> 上传图纸文件','{:url(\'index/blueprint/upDrawing_files\', [\'id\' => $blueprintOutsideList.id])}')" href="javascript:;"><i style="color:red" class="iconfont nav_right">&#xe71d;</i></a>
                    {else}
                    <a title="查看文件" onclick="x_admin_show('查看外图 <span class=\'layui-badge layui-bg-blue\'>{$blueprintOutsideList.drawing_external_id}</span> 图纸文件','{:url(\'index/blueprint/upDrawing_files\', [\'id\' => $blueprintOutsideList.id])}')" href="javascript:;"><i style="color:green" class="iconfont nav_right">&#xe6e6;</i></a>
                    {/if}
                </td>
                <td>
                    <?php
                    $count = getDetialExternal($blueprintOutsideList['drawing_external_id']);
                    ?>
                    {if $count == 0}
                    {$blueprintOutsideList.drawing_external_id}
                    {else/}
                     <a title="序号{$blueprintOutsideList.drawing_external_id}" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$blueprintOutsideList.drawing_external_id}</span> 的所有明细','{:url(\'index/Blueprint/blueprintInfo\', [\'modules\' => $blueprintOutsideList.drawing_external_id])}')" href="javascript:;"><i class="layui-icon " style="color: #1E9FFF">{$blueprintOutsideList.drawing_external_id}</i></a>
                    {/if}
                </td>
                <td>{$blueprintOutsideList.create_time}</td>
                <td>{$blueprintOutsideList.create_name}</td>
                <td>{$blueprintOutsideList.modify_name}</td>
                <td>{$blueprintOutsideList.update_time}</td>
                <td>{$blueprintOutsideList.remark}</td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
</div>
    <div class="page">
        {$blueprintOutside|raw}
    </div>
</div>
<script>
    /*删除*/
    function delete_(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var url = "<?php echo url('/index/Blueprint/deleteOutside'); ?>";
            var postData ={"id":id};
            $.post(url,postData,function (result) {
                if(result === 1 ){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else {
                    layer.alert("删除失败", {icon: 5});
                }
            },"json");
        });
    }


    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }

    function delAll (argument) {
        var data = tableCheck.getData();
        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            $.ajax({
                url:"/index/index/delall",
                type:"POST",
                dataType:"json",
                data:{
                    table:"hy_drawing_external",  //表名
                    data:data   //数据
                },
                success:function (res) {
                    layer.msg(res.message, {icon: 1});
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                },
            });
        });
    }
    function exeOrder() {
        var data = tableCheck.getData();
        var code = "{$order}";
        var index = parent.layer.getFrameIndex(window.name);
        if(data == ''){
            layer.msg('请选择数据');
            return;
        }
        //关闭当前弹出层
        x_admin_show('填写订单明细',"{:url('index/Order/addOrderDetail')}?id="+data+"&order="+code+"&type=w");

    }
</script>
</body>
</html>